#include "secondWindow.h"
#include "main.h"
#include "AdminManager.h"

secondWindow::secondWindow(QWidget *parent)
 :QWidget() , _parent(parent), _testLocaly(false), createUserWindow(0), currentUserItem(0)
{
	this->setWindowTitle("Configuration");
	setWindowIcon(QIcon("./images/Agora.png"));
	tempDisplay(this);
	initRightsList();
	this->show();

	SetKeyText(Qt::Key_Control, KeyPushValueLabel->text());
	dynamic_cast<Main*>(this->_parent)->SetPushToTalkKey(Qt::Key_Control);
	dynamic_cast<Main*>(this->_parent)->SetPushToTalkKeyText(KeyPushValueLabel->text());
}

void secondWindow::reload()
{
	emit this->reload(0);
	emit this->reload(2);
}

void	secondWindow::SetKeyText(int keyValue, QString &text)
{
	switch (keyValue)
	{
	case (Qt::Key_Control) :
		KeyPushValueLabel->setText("Control");
		break;
	case (Qt::Key_Tab) :
		KeyPushValueLabel->setText("Tab");
		break;
	case (Qt::Key_Backtab) :
		KeyPushValueLabel->setText("Backtab");
		break;
	case (Qt::Key_Backspace) :
		KeyPushValueLabel->setText("Backspace");
		break;
	case (Qt::Key_Return) :
		KeyPushValueLabel->setText("Return");
		break;
	case (Qt::Key_Enter) :
		KeyPushValueLabel->setText("Enter");
		break;
	case (Qt::Key_Insert) :
		KeyPushValueLabel->setText("Insert");
		break;
	case (Qt::Key_Delete) :
		KeyPushValueLabel->setText("Delete");
		break;
	case (Qt::Key_Pause) :
		KeyPushValueLabel->setText("Pause");
		break;
	case (Qt::Key_Print) :
		KeyPushValueLabel->setText("Print");
		break;
	case (Qt::Key_End) :
		KeyPushValueLabel->setText("End");
		break;
	case (Qt::Key_Left) :
		KeyPushValueLabel->setText("Left");
		break;
	case (Qt::Key_Up) :
		KeyPushValueLabel->setText("Up");
		break;
	case (Qt::Key_Right) :
		KeyPushValueLabel->setText("Right");
		break;
	case (Qt::Key_Down) :
		KeyPushValueLabel->setText("Down");
		break;
	case (Qt::Key_PageUp) :
		KeyPushValueLabel->setText("PageUp");
		break;
	case (Qt::Key_PageDown) :
		KeyPushValueLabel->setText("PageDown");
		break;
	case (Qt::Key_Shift) :
		KeyPushValueLabel->setText("Shift");
		break;
	case (Qt::Key_Alt) :
		KeyPushValueLabel->setText("Alt");
		break;
	case (Qt::Key_AltGr) :
		KeyPushValueLabel->setText("AltGr");
		break;
	case (Qt::Key_CapsLock) :
		KeyPushValueLabel->setText("CapsLock");
		break;
	case (Qt::Key_NumLock) :
		KeyPushValueLabel->setText("NumLock");
		break;
	case (Qt::Key_ScrollLock) :
		KeyPushValueLabel->setText("ScrollLock");
		break;
	case (Qt::Key_F1) :
		KeyPushValueLabel->setText("F1");
		break;
	case (Qt::Key_F2) :
		KeyPushValueLabel->setText("F2");
		break;
	case (Qt::Key_F3) :
		KeyPushValueLabel->setText("F3");
		break;
	case (Qt::Key_F4) :
		KeyPushValueLabel->setText("F4");
		break;
	case (Qt::Key_F5) :
		KeyPushValueLabel->setText("F5");
		break;
	case (Qt::Key_F6) :
		KeyPushValueLabel->setText("F6");
		break;
	case (Qt::Key_F7) :
		KeyPushValueLabel->setText("F7");
		break;
	case (Qt::Key_F8) :
		KeyPushValueLabel->setText("F8");
		break;
	case (Qt::Key_F9) :
		KeyPushValueLabel->setText("F9");
		break;
	case (Qt::Key_F10) :
		KeyPushValueLabel->setText("F10");
		break;
	case (Qt::Key_F11) :
		KeyPushValueLabel->setText("F11");
		break;
	case (Qt::Key_F12) :
		KeyPushValueLabel->setText("F12");
		break;
	default:
		KeyPushValueLabel->setText(text);
	}
}

void	secondWindow::keyPressEvent(QKeyEvent * eventArg)
{
	if (this->_getKey)
	{
		SetKeyText(eventArg->key(), eventArg->text());
		dynamic_cast<Main*>(this->_parent)->SetPushToTalkKey(eventArg->key());
		dynamic_cast<Main*>(this->_parent)->SetPushToTalkKeyText(KeyPushValueLabel->text());
		
	}
	else
		QWidget::keyPressEvent(eventArg);
}

void secondWindow::tempDisplay(QWidget *dest)
{
	// Creation du QTabWidget
    onglets = new QTabWidget(dest);
	
	 
    onglets->setGeometry(0, 0, 800, 300);
	//TODO ... set resizable(false)
	dest->setMinimumSize(800, 300);
	dest->setMaximumSize(800, 300);
    // Creation des pages
    page1 = new QWidget;
	page2 = new QWidget;
	page3 = new QWidget;
	page4 = new QWidget;

	// Creation du contenu des pages de widgets
        // Page 1
			nickLabel = new QLabel(page1);
			nickLabel->setText("Servername : ");
			nickLabel->setGeometry(250, 50, 100, 20);
			nickField = new QLineEdit(page1);
			nickField->setGeometry(350, 50, 200, 20);
			passLabel = new QLabel(page1);
			passLabel->setText("Password : ");
			passLabel->setGeometry(250, 100, 100, 20);
			passField = new QLineEdit(page1);
			passField->setGeometry(350, 100, 200, 20);
			privateLabel = new QLabel(page1);
			privateLabel->setText("Protected Network");
			privateLabel->setGeometry(250, 150, 100, 20);
			privateChk = new QCheckBox(page1);
			privateChk->setGeometry(350, 150, 20, 20);

		// Page 2


			QGridLayout *page2Layout = new QGridLayout;
			listUserRight = new QListWidget(page2);
			listUserRight->setSelectionMode(QAbstractItemView::SingleSelection);
			connect(listUserRight, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(selectUser(QListWidgetItem *, QListWidgetItem *)));
			listUserRightRights = new QListWidget(page2);
			listUserRightRights->setSelectionMode(QAbstractItemView::SingleSelection);
			saveRights = new QPushButton(tr("Save Selected User's Rights"));
			deleteUserButton = new QPushButton(tr("Delete Selected User"));
			createUserButton = new QPushButton(tr("Create New User"));
			connect(saveRights, SIGNAL(clicked()), this, SLOT(saveHostRight()));
			connect(deleteUserButton, SIGNAL(clicked()), this, SLOT(deleteUser()));
			connect(createUserButton, SIGNAL(clicked()), this, SLOT(createUser()));
			page2Layout->addWidget(listUserRight,0, 0, 1, 4);
			page2Layout->addWidget(listUserRightRights,0, 4, 1, 4);
			page2Layout->addWidget(saveRights, 1, 1, 1, 2);
			page2Layout->addWidget(deleteUserButton, 1, 3, 1, 2);
			page2Layout->addWidget(createUserButton, 1, 5, 1, 2);
			page2->setLayout(page2Layout);
			saveRights->setDisabled(true);

		// Page 3
		QGridLayout *page3Layout = new QGridLayout;
		QLabel *userBannedLabel = new QLabel(page1);
		userBannedLabel->setText("Users Banned :");
		QLabel *userNotBannedLabel = new QLabel(page1);
		userNotBannedLabel->setText("Users Not Banned :");
		listUserNotBanned = new QListWidget(this);
		connect(listUserNotBanned, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(selectNotBannedUser(QListWidgetItem *, QListWidgetItem *)));
		listUserBanned = new QListWidget(this);
		connect(listUserBanned, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(selectBannedUser(QListWidgetItem *, QListWidgetItem *)));
		banUserButton = new QPushButton(tr(">>"));
		connect(banUserButton, SIGNAL(clicked()), this, SLOT(banUser()));
		unbanUserButton = new QPushButton(tr("<<"));
		connect(unbanUserButton, SIGNAL(clicked()), this, SLOT(unbanUser()));
		page3Layout->addWidget(userNotBannedLabel, 0, 0, 1, 4);
		page3Layout->addWidget(listUserNotBanned, 1, 0, 10, 4);
		page3Layout->addWidget(userBannedLabel, 0, 5, 1, 4);
		page3Layout->addWidget(listUserBanned, 1, 5, 10, 4);
		page3Layout->addWidget(banUserButton, 5, 4, 1, 1);
		page3Layout->addWidget(unbanUserButton, 6, 4, 1, 1);
		page3->setLayout(page3Layout);
	
		// Page 4
			// Button GroupBox
			buttonsBox = new QGroupBox(tr("Output"));
			local = new QPushButton(tr("Test localy"));
			/*if (!dynamic_cast<Main*>(this->_parent)->IsAudioInStarted())
				micro = new QPushButton(tr("Stop micro"));
			else*/
				micro = new QPushButton(tr("Stop Micro"));
			/*if (!dynamic_cast<Main*>(this->_parent)->IsAudioOutStarted())
				speaker = new QPushButton(tr("Stop Loudspeakers"));
			else*/
				speaker = new QPushButton(tr("Stop Loudspeakers"));
			buttons = new QVBoxLayout;
			buttons->addWidget(local);
			buttons->addWidget(micro);
			buttons->addWidget(speaker);
			buttons->addStretch(1);
			buttonsBox->setLayout(buttons);

			connect(micro, SIGNAL(clicked()), this, SLOT(startMicro()));
			connect(speaker, SIGNAL(clicked()), this, SLOT(startSpeakers()));
			connect(local, SIGNAL(clicked()), this, SLOT(testlocaly()));

			// Micro frequence GroupBox
			frequenceBox = new QGroupBox(tr("Micro frequence"));
			kHz8 = new QRadioButton(tr("8 kHz"));
			kHz8->setChecked(true);
			connect(kHz8, SIGNAL(clicked()), this, SLOT(validParam()));
			kHz16 = new QRadioButton(tr("16 kHz"));
			connect(kHz16, SIGNAL(clicked()), this, SLOT(validParam()));
			kHz32 = new QRadioButton(tr("32 kHz"));
			connect(kHz32, SIGNAL(clicked()), this, SLOT(validParam()));
			frequence = new QVBoxLayout;
			frequence->addWidget(kHz8);
			frequence->addWidget(kHz16);
			frequence->addWidget(kHz32);
			frequence->addStretch(1);
			frequenceBox->setLayout(frequence);


			// Micro Format GroupBox
			formatBox = new QGroupBox(tr("Micro format"));
			stereo = new QRadioButton(tr("Stereo (16 bits)"));
			stereo->setChecked(true);
			connect(stereo, SIGNAL(clicked()), this, SLOT(validParam()));
			mono = new QRadioButton(tr("Mono (16 bits)"));
			connect(mono, SIGNAL(clicked()), this, SLOT(validParam()));
			format = new QVBoxLayout;
			format->addWidget(stereo);
			format->addWidget(mono);
			format->addStretch(1);
			formatBox->setLayout(format);


			// Encodage GroupBox
			encodageBox = new QGroupBox(tr("Encodage quality"));
			quality = new QSpinBox();
			quality->setRange(0, 10);
			quality->setWrapping(true);
			quality->setValue(5);
			validate = new QPushButton(tr("Validate"));
			encodage = new QVBoxLayout;
			encodage->addWidget(quality);
			encodage->addWidget(validate);
			encodage->addStretch(1);
			encodageBox->setLayout(encodage);
			connect(validate, SIGNAL(clicked()), this, SLOT(setAudioQuality()));	

			// Encodage GroupBox
			QGroupBox *voiceSendMethodBox = new QGroupBox(tr("Voice Send Method"));
			pushbutton = new QRadioButton(tr("Push to talk"));
			vadbutton = new QRadioButton(tr("Voice Activity Detection"));
			connect(pushbutton, SIGNAL(clicked()), this, SLOT(validVoiceSendMethod()));
			connect(vadbutton, SIGNAL(clicked()), this, SLOT(validVoiceSendMethod()));
			QGroupBox *vadBox = new QGroupBox(tr("Voice Activity Detection"));
			vadbutton->setChecked(true);
			QGroupBox *pushBox = new QGroupBox(tr("Push to talk"));
			QPushButton *setKeyPushButton = new QPushButton(tr("Set Key"), this);
			QLabel	*KeyPushStart = new QLabel("Current Key : ");
			KeyPushValueLabel = new QLabel("none");

			connect(setKeyPushButton, SIGNAL(clicked()), this, SLOT(setGetKey()));	

			QLabel	*vadtimetext = new QLabel("Check Time");
			QLabel	*vadLeveltext = new QLabel("Voice Level");
			vadtime = new QSlider();
			vadLevel = new QSlider();
			connect(vadtime, SIGNAL(valueChanged(int)), this, SLOT(validVoiceSendMethod()));
			connect(vadLevel, SIGNAL(valueChanged(int)), this, SLOT(validVoiceSendMethod()));
			
			vadLevel->setRange(0, 10000);
			vadLevel->setValue(500);
			vadtime->setRange(0, 2000);
			vadtime->setValue(200);
			
			QGridLayout *pushLayout = new QGridLayout;
			pushLayout->addWidget(setKeyPushButton, 0, 0, 1, 2);
			pushLayout->addWidget(KeyPushStart, 1, 0);
			pushLayout->addWidget(KeyPushValueLabel, 1, 1);
			pushBox->setLayout(pushLayout);

			QGridLayout *vadLayout = new QGridLayout;
			vadLayout->addWidget(vadtimetext, 0, 1);
			vadLayout->addWidget(vadLeveltext, 0, 0);
			vadLayout->addWidget(vadtime, 1, 1);
			vadLayout->addWidget(vadLevel, 1, 0);
			vadBox->setLayout(vadLayout);

			QGridLayout *voiceSendMethodLayout = new QGridLayout;
			voiceSendMethodLayout->addWidget(vadbutton, 0, 0, 1, 5);
			voiceSendMethodLayout->addWidget(pushbutton, 1, 0, 1, 5);
			voiceSendMethodLayout->addWidget(vadBox, 2, 0, 1, 3);
			voiceSendMethodLayout->addWidget(pushBox, 2, 3, 1, 2);
			voiceSendMethodBox->setLayout(voiceSendMethodLayout);





			// Display
			grid = new QGridLayout;
			grid->addWidget(buttonsBox, 1, 0, 1, 2);
			grid->addWidget(frequenceBox, 1, 2, 1, 1);
			grid->addWidget(formatBox, 1, 3, 1, 2);
			grid->addWidget(encodageBox, 1, 5, 1, 1);
			grid->addWidget(voiceSendMethodBox, 1, 6, 1, 3);
			
		//	grid->addWidget(bandwidthBox,2 , 3);
			page4->setLayout(grid);


	// Ajout des onglets au QTabWidget, en indiquant la page qu'ils contiennent
	onglets->addTab(page2, "User's List and User's rights");
	onglets->addTab(page3, "Users banned");
	onglets->addTab(page4, "Audio");
	connect(onglets, SIGNAL(currentChanged(int)), this, SLOT(reloadUserList(int)));
	connect(this, SIGNAL(reload(int)), this, SLOT(reloadUserList(int)));
}


void secondWindow::startMicro()
{
	if (!dynamic_cast<Main*>(this->_parent)->IsAudioInStarted())
	{
		dynamic_cast<Main*>(this->_parent)->GetAgora()->StartAudioInput();
		dynamic_cast<Main*>(this->_parent)->SetAudioInStarted(true);
		this->micro->setText("Stop Micro");
	}
	else
	{
		dynamic_cast<Main*>(this->_parent)->GetAgora()->StopAudioInput();
		dynamic_cast<Main*>(this->_parent)->SetAudioInStarted(false);
		micro->setText("Start Micro");
	}
}


void secondWindow::startSpeakers()
{
	if (!dynamic_cast<Main*>(this->_parent)->IsAudioOutStarted())
	{
		dynamic_cast<Main*>(this->_parent)->GetAgora()->StartAudioOut();
		dynamic_cast<Main*>(this->_parent)->SetAudioOutStarted(true);
		speaker->setText("Stop Loudspeakers");
	}
	else
	{
		dynamic_cast<Main*>(this->_parent)->GetAgora()->StopAudioOut();
		dynamic_cast<Main*>(this->_parent)->SetAudioOutStarted(false);
		speaker->setText("Start Loudspeakers");
	}
}

int secondWindow::getAudioInKey_Main()
{
	return dynamic_cast<Main*>(this->_parent)->getAudioInKey();
}

void secondWindow::setAudioQuality()
{
	Main* main = dynamic_cast<Main*>(this->_parent);
	main->_qualityAudio = quality->value();
	main->GetAgora()->SetEncoderQuality(main->_encoderKey, main->_qualityAudio);
}

void secondWindow::reloadUserList(int tab)
{
	Main* main = dynamic_cast<Main*>(this->_parent);

	if (tab == 0)
	{
		bool notEmpty = false;
		
		std::map<unsigned int, IUser*>::iterator it = main->_mapIdIUser.begin();
		std::map<unsigned int, IUser*>::iterator itend = main->_mapIdIUser.end();
		this->listUserRight->clear();
		for(;it != itend; ++it)
		{
			notEmpty = true;
			this->listUserRight->addItem(new QListWidgetItem(*(main->iconPeople),(*it).second->GetLogin().c_str(), 0, (*it).first));
		}
		if (notEmpty)
		{
			this->listUserRight->setItemSelected(this->listUserRight->item(0), true);
			selectUser(this->listUserRight->item(0), 0);
			listUserRightRights->setEnabled(main->_hostRight->GetCanEditUser());	
		}
		else
		{
			listUserRightRights->setEnabled(false);
		}
		deleteUserButton->setEnabled(notEmpty);
		createUserButton->setEnabled(main->IsConnected() && main->_hostRight->GetCanEditUser());
	}
	else if (tab == 2)
	{
		std::map<unsigned int, IUser*>::iterator it = main->_mapIdIUser.begin();
		std::map<unsigned int, IUser*>::iterator itend = main->_mapIdIUser.end();
		this->listUserNotBanned->clear();
		this->listUserBanned->clear();
		for(;it != itend; ++it)
		{
			if (main->IsBanned((*it).first))
			{
				this->listUserBanned->addItem(new QListWidgetItem(*(main->iconPeople),(*it).second->GetLogin().c_str(), 0, (*it).first));
			}
			else
			{
				this->listUserNotBanned->addItem(new QListWidgetItem(*(main->iconPeople),(*it).second->GetLogin().c_str(), 0, (*it).first));
			}
		}
		this->banUserButton->setEnabled(main->IsConnected() && main->_hostRight->GetCanBanUser());
		this->unbanUserButton->setEnabled(main->IsConnected() && main->_hostRight->GetCanBanUser());
	}

}

void secondWindow::addRights(const char *txt)
{
	QListWidgetItem* test = new QListWidgetItem(txt);
	test->setCheckState(Qt::Unchecked);
	this->listUserRightRights->addItem(test);
}

void secondWindow::initRightsList()
{
	addRights("Can Change Login");
	addRights("Can Change Password");
	addRights("Can Change Channel");
	addRights("Can Create Channel");
	addRights("Can Delete Channel");
	addRights("Can Move Channel");
	addRights("Can Kick User");
	addRights("Can Ban User");
	addRights("Can Edit User");
	listUserRightRights->setDisabled(true);
}


void secondWindow::setRights(unsigned int row, bool checked)
{
	if (checked)
		listUserRightRights->item(row)->setCheckState(Qt::Checked);
	else
		listUserRightRights->item(row)->setCheckState(Qt::Unchecked);
}


void secondWindow::selectUser(QListWidgetItem *current, QListWidgetItem *)
{
	Main* main = dynamic_cast<Main*>(this->_parent);
	
	if (current)
	{
		currentUserItem = current;
		_userIdforRights = current->type();
		saveRights->setDisabled(false);
		IHostRight *rights = main->_userHostRight[current->type()];
		if (rights)
		{
			setRights(0, rights->GetCanChangeLogin());
			setRights(1, rights->GetCanChangePassword());
			setRights(2, rights->GetCanChangeChannel());
			setRights(3, rights->GetCanCreateChannel());
			setRights(4, rights->GetCanDeleteChannel());
			setRights(5, rights->GetCanMoveChannel());
			setRights(6, rights->GetCanKickUser());
			setRights(7, rights->GetCanBanUser());
			setRights(8, rights->GetCanEditUser());
		}
	}
	
}

void secondWindow::validParam()
{
	Main* main = dynamic_cast<Main*>(this->_parent);

	if (this->kHz8->isChecked())
	{
		main->_freq = NARROWBAND;
	}
	else if (this->kHz16->isChecked())
	{
		main->_freq = WIDEBAND;
	}
	else if (this->kHz32->isChecked())
	{
		main->_freq = ULTRAWIDEBAND;
	}

	if (this->stereo->isChecked())
	{
		main->_format = STEREO16;
	}
	else if (this->mono->isChecked())
	{
		main->_format = MONO16;
	}
	
	main->GetAgora()->StopAudioInput(); //optionnel
	
	
	main->GetAgora()->RemoveAudioInput(this->getAudioInKey_Main());
	main->_audioInKey = main->GetAgora()->CreateDefaultMicro(main->_freq, main->_format);
	main->GetAgora()->SetVoiceActivityDetection(main->_audioInKey, true);
	main->_encoderKey = SPEEX;
	main->GetAgora()->SetEncoderForAudioInput(main->_encoderKey, main->_audioInKey);
	main->GetAgora()->SetEncoderQuality(main->_encoderKey, main->_qualityAudio);
	if (main->IsAudioInStarted())
		main->GetAgora()->StartAudioInput();
}

void secondWindow::validVoiceSendMethod()
{
	Main* main = dynamic_cast<Main*>(this->_parent);

	if (this->pushbutton->isChecked())
	{
		main->SetPushToTalk(true);
		main->GetAgora()->StopAudioInput();
		main->SetVAD(false, vadLevel->value(), vadtime->value());
	}
	else if (this->vadbutton->isChecked())
	{
		if (main->IsAudioInStarted())
			main->GetAgora()->StartAudioInput();
		main->SetPushToTalk(false);
		main->SetVAD(true, vadLevel->value(), vadtime->value());
	}
}

void secondWindow::saveHostRight()
{
	Main* main = dynamic_cast<Main*>(this->_parent);
	IHostRight *rights = main->_userHostRight[this->_userIdforRights];

	if (rights)
	{
		
		rights->SetCanChangeLogin(listUserRightRights->item(0)->checkState() == Qt::Checked);
		rights->SetCanChangePassword(listUserRightRights->item(1)->checkState() == Qt::Checked);
		rights->SetCanChangeChannel(listUserRightRights->item(2)->checkState() == Qt::Checked);
		rights->SetCanCreateChannel(listUserRightRights->item(3)->checkState() == Qt::Checked);
		rights->SetCanDeleteChannel(listUserRightRights->item(4)->checkState() == Qt::Checked);
		rights->SetCanMoveChannel(listUserRightRights->item(5)->checkState() == Qt::Checked);
		rights->SetCanKickUser(listUserRightRights->item(6)->checkState() == Qt::Checked);
		rights->SetCanBanUser(listUserRightRights->item(7)->checkState() == Qt::Checked);
		rights->SetCanEditUser(listUserRightRights->item(8)->checkState() == Qt::Checked);
		AgoraClient::AdminManager::GetAdminManager()->SetUserHostRight(this->_userIdforRights, rights);

	}
}

void secondWindow::testlocaly()
{
	if (!_testLocaly)
	{
		dynamic_cast<Main*>(this->_parent)->GetAgora()->SetLocalTest(true);
		local->setText("Stop Local Test");
		_testLocaly = true;
	}
	else
	{
		dynamic_cast<Main*>(this->_parent)->GetAgora()->SetLocalTest(false);
		local->setText("Start Local Test");
		_testLocaly = false;
	}

}
void secondWindow::setGetKey()
{
	SetGetKey(true);
}

void secondWindow::SetGetKey(bool val)
{
	this->_getKey = val;
}


void secondWindow::deleteUser()
{
	if (currentUserItem)
	{
		AgoraClient::AdminManager::GetAdminManager()->DeleteUser(currentUserItem->type());
	}
}

void secondWindow::createUser()
{
	if (createUserWindow == 0)
	{
		createUserWindow = new CreateUserWindow();
	}
	createUserWindow->showNormal();
}


void			secondWindow::banUser()
{
	AgoraClient::AdminManager::GetAdminManager()->BanUserFromServer(_userIdforUserNotBanned);
}

void			secondWindow::unbanUser()
{
	AgoraClient::AdminManager::GetAdminManager()->UnbanUserFromServer(_userIdforUserBanned);
}

void			secondWindow::selectNotBannedUser(QListWidgetItem *current, QListWidgetItem *)
{
	if (current)
		this->_userIdforUserNotBanned = current->type();
}

void			secondWindow::selectBannedUser(QListWidgetItem *current, QListWidgetItem *)
{
	if (current)
		this->_userIdforUserBanned = current->type();
}